package com.study.subpub;

/**
 * 参考：https://blog.csdn.net/lxw1005192401/article/details/80986004
 * 例子中遍历队列编写错误，已修改
 * @Author HBZ
 * @Date 2020/7/21 15:51
 * @Description
 */
public class Test {
    public static void main(String[] args) {
        SubscribePublish<String> subscribePublish = new SubscribePublish<String>("订阅器");
        IPublisher<String> publisher1 = new PublisherImpOne<String>("发布者1");
        ISubcriber<String> subcriber1 = new SubcriberImpOne<String>("订阅者1");
        ISubcriber<String> subcriber2 = new SubcriberImpOne<String>("订阅者2");
        subcriber1.subcribe(subscribePublish);
        subcriber2.subcribe(subscribePublish);
        publisher1.publish(subscribePublish, "welcome",true);
        publisher1.publish(subscribePublish, "to",true);
        publisher1.publish(subscribePublish, "1",false);
        publisher1.publish(subscribePublish, "2",false);
        publisher1.publish(subscribePublish, "3",false);
        publisher1.publish(subscribePublish, "4",false);
        publisher1.publish(subscribePublish, "5",false);
        publisher1.publish(subscribePublish, "6",false);
        publisher1.publish(subscribePublish, "7",false);
    }
}
